﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Windows.Foundation;
using Windows.UI.Core;
using Windows.UI.Popups;
using Windows.UI.Xaml;
using wUniAppPCL;

namespace wUniApp.Controls
{
  public partial class wMessage : wBaseMessage
  {
    public override async Task<wMessageDlgResultEnum> Show(string message, wMessageDlgTypeEnum type, string title = "")
    {
      var res = wMessageDlgResultEnum.Cancel;
      var messageDialog = new MessageDialog(message, title);

      switch (type)
      {
        case wMessageDlgTypeEnum.YesNo:
          {
            messageDialog.Commands.Add(new UICommand(txYes, delegate(IUICommand command) { res = wMessageDlgResultEnum.Yes; }));
            messageDialog.Commands.Add(new UICommand(txNo));
            break;
          }
        case wMessageDlgTypeEnum.OK:
          {
            messageDialog.Commands.Add(new UICommand(txOK));
            res = wMessageDlgResultEnum.OK;
            break;
          }

      }


      CoreDispatcher dispatcher = Window.Current.Dispatcher;
      await messageDialog.ShowAsync();

      return res;
    }
  }
}
